package com.satan.entity.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName ResultVo
 * @Description TODO
 * @date 2022/3/28 18:49
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultEntity<T> {

    private boolean success;

    private int code;

    private String msg;

    private T data;


    public static <T> ResultEntity<T> success(T data) {
        return new ResultEntity(true, 200,"success", data);
    }

    public static <T> ResultEntity<T> fail(ResCode resCode) {
        return new ResultEntity(false, resCode.getCode(), resCode.getMsg(), null);
    }

}
